
svm_recp = recipe(diagnosis~.,data = train_data) |>
 
  step_smotenc(diagnosis,over_ratio=0.5 ,neighbors=1,seed=123)

svm_spec = svm_rbf() |>
  set_engine("kernlab") |>
  set_mode("classification")

svm_flow = workflow() |>
  add_recipe(svm_recp) |>
  add_model(svm_spec)


svm_fit = fit(svm_flow,data = train_data)
svm_predict = augment(svm_fit,new_data=test_data)

svm_auc = roc_auc(data = svm_predict,truth = diagnosis,.pred_1,event_level="second")
svm_acc = accuracy(data = svm_predict,truth = diagnosis,.pred_class)
svm_sens = sensitivity(data=svm_predict,truth = diagnosis,.pred_class,event_level = "second")
svm_spec = specificity(data=svm_predict,truth = diagnosis,.pred_class,event_level = "second")
svm_ppv = ppv(data=svm_predict,truth = diagnosis,.pred_class,event_level = "second")
svm_conf_mat = conf_mat(data=svm_predict,truth = diagnosis,.pred_class)
svm_f_meas = f_meas(data=svm_predict,truth = diagnosis,.pred_class,event_level = 'second')

# svm_evaluation_table <- tibble(
#   metric = c("auc", "acc","sens","spec","ppv"),
#   value = c(auc$.estimate, acc$.estimate,sens$.estimate,spec$.estimate,ppv$.estimate)
# )

# svm_evaluation_table

# conf_mat